Skip to content

feat: support disablement of APM Tracing (the product) #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dmehala
Copy link
Collaborator

@dmehala dmehala commented Jul 10, 2025

Description

Supersede #217

Motivation

  1. Simplify the Implementation
    While the original approach worked, I identified a more straightforward way to reach the same goals with fewer moving parts and a clearer mental model.
  2. Clarify Underspecified Behavior
    Some behaviors, especially around context extraction, aren’t fully defined in the RFC yet. Rather than making assumptions, we took the opportunity to clarify and solidify these behaviors.
  3. Improve Long-Term Maintainability
    Reusing existing constructs and patterns makes the codebase easier to understand, test, and evolve. This rework brings the implementation closer to that goal.

Improvements (non-exhaustive)

  • Avoided injecting empty tracing context, which required adding support to delete headers on the integration side.
  • Added more comprehensive tests to cover edge cases.
  • Aligned API design for trace source attribution, moved from injection options to span-level attributes for clearer semantics.
  • Simplified sampling logic by using existing rule-based mechanisms rather than introducing new types or abstractions.
  • Clarified the API for controlling stats computation, improving long term maintainability.
  • Validated extracted trace source to ensure consistency and reduce potential for errors.
  • Reused existing concepts and components, avoiding the need for new structures and reducing the risk of regressions.

@dmehala dmehala force-pushed the dmehala/disable-tracing branch 6 times, most recently from 33c8913 to c65356d Compare July 17, 2025 15:11
@pr-commenter
Copy link

pr-commenter bot commented Jul 17, 2025

Benchmarks

Benchmark execution time: 2025-07-17 15:37:08

Comparing candidate commit 3ae4854 in PR branch dmehala/disable-tracing with baseline commit 31f263f in branch main.

Found 0 performance improvements and 1 performance regressions! Performance is the same for 0 metrics, 0 unstable metrics.

scenario:BM_TraceTinyCCSource

  • 🟥 execution_time [+3.940ms; +4.051ms] or [+5.418%; +5.571%]

@dmehala dmehala force-pushed the dmehala/disable-tracing branch 2 times, most recently from ba4291a to 2b1e5a8 Compare July 17, 2025 15:23
@dmehala dmehala force-pushed the dmehala/disable-tracing branch from 2b1e5a8 to 55684de Compare July 17, 2025 15:26
@dmehala dmehala marked this pull request as ready for review July 17, 2025 15:26
@dmehala dmehala requested a review from a team as a code owner July 17, 2025 15:26
@dmehala dmehala requested review from zacharycmontoya and removed request for a team July 17, 2025 15:26
@codecov-commenter
Copy link

codecov-commenter commented Jul 17, 2025

Codecov Report

Attention: Patch coverage is 90.82569% with 10 lines in your changes missing coverage. Please review.

Project coverage is 86.51%. Comparing base (31f263f) to head (3ae4854).

Files with missing lines Patch % Lines
include/datadog/trace_source.h 46.15% 7 Missing ⚠️
src/datadog/telemetry/telemetry_impl.cpp 0.00% 2 Missing ⚠️
include/datadog/dict_writer.h 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #224      +/-   ##
==========================================
+ Coverage   86.45%   86.51%   +0.05%     
==========================================
  Files          80       82       +2     
  Lines        5251     5347      +96     
==========================================
+ Hits         4540     4626      +86     
- Misses        711      721      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +8 to +19
bool validate_trace_source(StringView source_str) {
if (source_str.size() > 2) return false;

auto maybe_ts_uint = parse_uint64(source_str, 10);
if (maybe_ts_uint.if_error()) return false;

// Bit twiddling magic is coming from
// <http://www.graphics.stanford.edu/~seander/bithacks.html> <3.
auto is_power_of_2 = [](uint64_t v) -> bool { return v && !(v & (v - 1)); };

return is_power_of_2(*maybe_ts_uint);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You document that it is a bitmap, but then require that only one flag be set (that it is a power of two).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants